package controller;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.FileNotFoundException;
import java.io.IOException;

import util.Config;
import model.*;
import view.*;
import view.mh.GUItest;

/**
 * Wetter-Control-Objekt
 * @author Bernd Taube
 * @author Jakobus B�ttcher
 * @version 1.0
 *
 */
public class Controller implements ActionListener, ItemListener {

	// Instanz-Variablen
	
    private Model model;
    private GUItest view;
     private WeatherModel weatherObject = null;
    private Object itemArgument;
    public static Actions action;
    
    /**
     * Konstruktor
     * @throws IOException 
     * @throws FileNotFoundException 
     */
    public Controller() {
  
        this.model = new Model();   
        view = new GUItest(this);
        this.model.addObserver(this.view);
        this.view.setVisible(true);
        
       
    }
    
    
    @Override
    public void itemStateChanged(ItemEvent e){
    	if (e.getStateChange() == ItemEvent.SELECTED){
    		this.itemArgument = e.getItem();
    	}
    }
    
    /**
     * Und Action!
     */
    @Override
    public void actionPerformed(ActionEvent arg0) {
    	String action = arg0.getActionCommand();
    		
    	if (action == Actions.GET_AIRPORTS.command()) {
    		this.model.retrieveAirportsFromDB((CountryModel)itemArgument);
    	
    	}
    	
        if (action == Actions.GET_TEMPARATURE.command()) {
      
        }
        
        if (action == Actions.GET_CLOUD.command()) {
          
        
        }
        
        if (action == Actions.ACTUALIZE.command()) {
        	System.out.println("Aktualisierung");
        }
    }
}